-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed LTI duplicate roster error #2213
base: master
Are you sure you want to change the base?
Conversation
WalkthroughWalkthroughThe changes introduce a mechanism for handling warnings during roster uploads in the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CoursesController
participant Roster
User->>CoursesController: Upload roster
CoursesController->>Roster: Process roster data
Roster-->>CoursesController: Return warnings/errors
CoursesController->>CoursesController: Check for warnings
alt Warnings exist
CoursesController->>User: Display warnings
end
alt Errors exist
CoursesController->>User: Display errors
end
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- app/controllers/courses_controller.rb (4 hunks)
Additional comments not posted (1)
app/controllers/courses_controller.rb (1)
556-559
: LGTM: Successfully implemented roster warning systemThe changes successfully implement a warning system for roster uploads, focusing on detecting and reporting duplicate email addresses. This aligns well with the PR objectives of allowing roster synchronization to proceed while alerting users to potential issues.
Key improvements:
- Added a mechanism to collect and store warnings during the roster processing.
- Implemented specific handling for duplicate email warnings.
- Added logic to display warnings to the user after roster upload.
The implementation is sound and doesn't introduce any apparent bugs or issues. However, there are opportunities for minor improvements in naming conventions and error/warning handling, as mentioned in the previous comments.
Overall, this change enhances the user experience by providing more informative feedback during the roster upload process.
Also applies to: 805-805, 953-957, 960-961
unless @roster_warnings.nil? | ||
w = @roster_warnings.keys.join('\n') | ||
flash[:error] = w | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider improving the warning display mechanism
The new warning system is a good addition, but there are a few points to consider:
- Using
flash[:error]
for warnings might be confusing. Consider usingflash[:warning]
instead to differentiate between errors and warnings. - Joining warning messages with '\n' might not render properly in HTML. Consider using
<br>
for line breaks or formatting the warnings as an HTML list. - The success message is still displayed even when there are warnings. Consider adjusting the logic to provide a more nuanced feedback.
Here's a suggested improvement:
if @roster_warnings.present?
flash[:warning] = "Roster uploaded with warnings:"
flash[:warning] += "<ul>"
@roster_warnings.keys.each do |warning|
flash[:warning] += "<li>#{warning}</li>"
end
flash[:warning] += "</ul>"
flash[:partial_success] = "Roster updated, but with some warnings. Please review."
else
flash[:success] = "Successfully updated roster!"
end
flash[:html_safe] = true
This change separates warnings from errors, formats the warnings as an HTML list, and provides a more accurate success message.
msg = "Validation failed: Duplicate email #{cud[:email]}" | ||
if !rosterErrors.key?(msg) | ||
rosterErrors[msg] = [] | ||
msg = "Warning : Duplicate email #{cud[:email]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add that this duplicate email was ignored / which line the duplicate email was on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me, verified behavior on both roster upload and LTI roster sync
An error occurs when we have a roster with duplicate email addresses, so changed it to only a warning.
Description
Before: When we sync the roster to a LTI course that has duplicate users, an error occured.
After: When we sync the roster, the sync works, but a warning is produced.
Motivation and Context
The LTI Test Course has duplicate users, and the roster sync was failing.
How Has This Been Tested?
I created a new course in my development environment, and linked the LTI test course, and synced the roster.
Types of changes
Checklist:
overcommit --install && overcommit --sign
to use pre-commit hook for lintingOther issues / help required
If unsure, feel free to submit first and we'll help you along.